function axios({method, url, params, data}) {
    return new Promise((resolve, reject) => {
        // 创建xhr对象
        const xhr = new XMLHttpRequest();
        
        // 初始化请求
        let str = '';

        for(let k in params) {
            str += `${k}=${params[k]}&`;
        }
        console.log(str)
        str = str.slice(0, -1);
        xhr.open(method, url+'?'+str);

        // 发送请求
        if(method === 'GET' || method === 'POST' || method === 'PUT' || method === 'DELETE') {
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.send(JSON.stringify(data));
        } else {
            xhr.send();
        }

        xhr.onreadystatechange = function() {
            if(xhr.readyState === 4 && xhr.status === 200) {
                resolve(xhr.responseText);
            }
        }
    })
}